package com.nbsaas.boot.customer.rest.convert;

import com.nbsaas.boot.customer.data.entity.CustomerAddress;
import com.nbsaas.boot.customer.api.domain.simple.CustomerAddressSimple;

import com.nbsaas.boot.rest.api.Converter;

/**
* 收货地址-列表对象转换器
*/

public class CustomerAddressSimpleConvert implements Converter<CustomerAddressSimple, CustomerAddress> {




@Override
public CustomerAddressSimple convert(CustomerAddress source) {
    CustomerAddressSimple result = new CustomerAddressSimple();


               try {
                   if(source.getArea()!=null){
                       result.setArea(source.getArea().getId());
                   }
                } catch (Exception ignored) { }

                result.setNote(source.getNote());
                result.setAddress(source.getAddress());
                result.setLng(source.getLng());

               try {
                   if(source.getCity()!=null){
                       result.setCity(source.getCity().getId());
                   }
                } catch (Exception ignored) { }

                result.setPostalCode(source.getPostalCode());
                result.setLabel(source.getLabel());
                result.setAddDate(source.getAddDate());

                try {
                    if(source.getCustomer()!=null){
                        result.setCustomerName(source.getCustomer().getName());
                    }
                } catch (Exception ignored) { }


               try {
                   if(source.getProvince()!=null){
                       result.setProvince(source.getProvince().getId());
                   }
                } catch (Exception ignored) { }


                try {
                    if(source.getCity()!=null){
                        result.setCityName(source.getCity().getName());
                    }
                } catch (Exception ignored) { }

                result.setPhone(source.getPhone());

                try {
                    if(source.getArea()!=null){
                        result.setAreaName(source.getArea().getName());
                    }
                } catch (Exception ignored) { }

                result.setName(source.getName());
                result.setHouseNo(source.getHouseNo());
                result.setTel(source.getTel());
                if(source.getStoreState()!=null){
                    result.setStoreStateName(String.valueOf(source.getStoreState()));
                }
                result.setStoreState(source.getStoreState());

                try {
                    if(source.getProvince()!=null){
                        result.setProvinceName(source.getProvince().getName());
                    }
                } catch (Exception ignored) { }

                result.setId(source.getId());
                result.setLat(source.getLat());

               try {
                   if(source.getCustomer()!=null){
                       result.setCustomer(source.getCustomer().getId());
                   }
                } catch (Exception ignored) { }

                result.setLastDate(source.getLastDate());


    return result;
}

}